package com.minxyz.stock.service;

import com.minxyz.stock.repository.StockRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

@Slf4j
@Service
public class StockService {

    @Autowired
    private StockRepository stockRepository;

    @Transactional
    public void quota() {
        int result = stockRepository.update(1);
        if(result==0)
            throw new RuntimeException("扣减库存失败");
        log.debug("{}", result);
    }

}
